home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cxtw107.zip / CXT_ME.CMD < prev    next >
OS/2 REXX Batch file  |  1995-07-20  |  12KB  |  347 lines

  1. ;*****************************************************************************
  2. ;
  3. ;   CXT_ME.CMD - MicroEMACS MACRO FUNCTIONS FOR
  4. ;
  5. ;       CSTN (TM) C STRUCTURE TREE NAVIGATOR
  6. ;       CFTN (TM) C FUNCTION TREE NAVIGATOR
  7. ;
  8. ;   Copyright (C) Juergen Mueller (J.M.) 1992-1995
  9. ;   All rights reserved.
  10. ;
  11. ;   You are expressly prohibited from selling this software in any form,
  12. ;   distributing it with another product, or removing this notice.
  13. ;
  14. ;   Limited permission is given to registered CXT users to modify this
  15. ;   file for their own personal use only. This file may not be used for any
  16. ;   purpose other than in conjunction with the CXT software package.
  17. ;
  18. ;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  19. ;   EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE
  20. ;   IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR
  21. ;   PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  22. ;   PROGRAM AND DOCUMENTATION IS WITH YOU.
  23. ;
  24. ;   written by: Juergen Mueller, Aldingerstrasse 22, D-70806 Kornwestheim,
  25. ;               GERMANY
  26. ;
  27. ;   FILE       : CXT_ME.CMD
  28. ;   REVISION   : 26-Mar-1995
  29. ;                12:43:59
  30. ;
  31. ;*****************************************************************************
  32.  
  33. ; NOTE: for OS/2 you should exchange "cftn" with "cftn4os2"
  34. ; NOTE: for OS/2 you should exchange "cstn" with "cstn4os2"
  35. ; NOTE: for NT you should exchange "cftn" with "cftn4nt"
  36. ; NOTE: for NT you should exchange "cstn" with "cstn4nt"
  37.  
  38. ;*****************************************************************************
  39. ;**** write initial message ****
  40. ;*****************************************************************************
  41. write-message "Loading CXT macro package"
  42.  
  43. ;*****************************************************************************
  44. ;**** macro package initialization section ****
  45. ;*****************************************************************************
  46. set %cxt_item ""                ; set internal variables
  47. set %cxt_file ""
  48. set %cxt_line ""
  49. set %cxtn_cmd ""
  50. set %char_set "_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  51.  
  52. set %cft_base &env "CFTNBASE"   ; get environment variables, if set
  53. !if &seq &len %cft_base 0
  54.   set %cft_base &env "CXTNBASE"
  55.  
  56.   !if &seq &len %cft_base 0
  57.     set %cft_base ""
  58.   !endif
  59. !endif
  60.  
  61. set %cst_base &env "CSTNBASE"   ; get environment variables, if set
  62. !if &seq &len %cst_base 0
  63.   set %cst_base &env "CXTNBASE"
  64.  
  65.   !if &seq &len %cst_base 0
  66.     set %cst_base ""
  67.   !endif
  68. !endif
  69.  
  70. ;*****************************************************************************
  71. ;**** definition of user macros ****
  72. ;*****************************************************************************
  73.  
  74. ;**** find function ****
  75. store-procedure cft
  76.         execute-procedure _extract_item         ; get tagged item
  77.         execute-procedure _cxt_cft
  78. !endm
  79.  
  80. ;**** find data type ****
  81. store-procedure cst
  82.         execute-procedure _extract_item         ; get tagged item
  83.         execute-procedure _cxt_cst
  84. !endm
  85.  
  86. ;**** find function ****
  87. store-procedure cftmark
  88.         execute-procedure _extract_marked_item  ; get marked item
  89.         execute-procedure _cxt_cft
  90. !endm
  91.  
  92. ;**** find function ****
  93. store-procedure cstmark
  94.         execute-procedure _extract_marked_item  ; get marked item
  95.         execute-procedure _cxt_cst
  96. !endm
  97.  
  98. ;**** find function ****
  99. store-procedure cftfind
  100.         set %cxt_item "CFT function name: "
  101.         set %cxt_item @%cxt_item                ; get user input
  102.         execute-procedure _cxt_cft
  103. !endm
  104.  
  105. ;**** find data type ****
  106. store-procedure cstfind
  107.         set %cxt_item "CST data type name: "
  108.         set %cxt_item @%cxt_item                ; get user input
  109.         execute-procedure _cxt_cst
  110. !endm
  111.  
  112. ;**** set CFT database name ****
  113. store-procedure cftbase
  114.         set %cft_base "CFT database name: "
  115.         set %cft_base @%cft_base                ; get user input
  116. !endm
  117.  
  118. ;**** set CST database name ****
  119. store-procedure cstbase
  120.         set %cst_base "CST database name: "
  121.         set %cst_base @%cst_base                ; get user input
  122. !endm
  123.  
  124. ;**** set CFT and CST database name ****
  125. store-procedure cxtbase
  126.         set %cxt_base "CFT and CST database name: "
  127.         set %cxt_base @%cxt_base                ; get user input
  128.         set %cft_base %cxt_base
  129.         set %cst_base %cxt_base
  130. !endm
  131.  
  132. ;**** CFT file list
  133. store-procedure cftfile
  134.         write-message "Extracting CFT filelist"
  135.  
  136.         !if ¬ &seq &len %cft_base 0
  137.           set %tmp &cat &cat "-f" %cft_base " "         ; database access path
  138.         !else
  139.           set %tmp ""
  140.         !endif
  141.  
  142.         set %cxtn_cmd &cat "cftn -F " %tmp
  143.         pipe-command %cxtn_cmd          ; perform database access, shell command
  144. !endm
  145.  
  146. ;**** CST file list
  147. store-procedure cstfile
  148.         write-message "Extracting CST filelist"
  149.  
  150.         !if ¬ &seq &len %cst_base 0
  151.           set %tmp &cat &cat "-f" %cst_base " "         ; database access path
  152.         !else
  153.           set %tmp ""
  154.         !endif
  155.  
  156.         set %cxtn_cmd &cat "cstn -F " %tmp
  157.         pipe-command %cxtn_cmd          ; perform database access, shell command
  158. !endm
  159.  
  160. ;*****************************************************************************
  161. ;**** internal macro execution functions ****
  162. ;*****************************************************************************
  163.  
  164. ;*****************************************************************************
  165. ;* CFT front-end *
  166. ;*****************************************************************************
  167. store-procedure _cxt_cft
  168.         !if &seq &len %cxt_item 0
  169.           write-message "No function selected"
  170.           !return
  171.         !endif
  172.  
  173.         write-message &cat &cat "Searching for function: '" %cxt_item "'"
  174.  
  175.         !if ¬ &seq &len %cft_base 0
  176.           set %tmp &cat &cat "-f" %cft_base " "         ; database access path
  177.         !else
  178.           set %tmp ""
  179.         !endif
  180.  
  181.         set %cxtn_cmd &cat &cat "cftn -b " %tmp %cxt_item
  182.         execute-procedure _cxt_search                   ; start search
  183. !endm
  184.  
  185. ;*****************************************************************************
  186. ;* CST front-end *
  187. ;*****************************************************************************
  188. store-procedure _cxt_cst
  189.         !if &seq &len %cxt_item 0
  190.           write-message "No data type selected"
  191.           !return
  192.         !endif
  193.  
  194.         write-message &cat &cat "Searching for data type: '" %cxt_item "'"
  195.  
  196.         !if ¬ &seq &len %cst_base 0
  197.           set %tmp &cat &cat "-f" %cst_base " "         ; database access path
  198.         !else
  199.           set %tmp ""
  200.         !endif
  201.  
  202.         set %cxtn_cmd &cat &cat "cstn -b " %tmp %cxt_item
  203.         execute-procedure _cxt_search                   ; start search
  204. !endm
  205.  
  206. ;*****************************************************************************
  207. ;* the database retrieval function *
  208. ;*****************************************************************************
  209. store-procedure _cxt_search
  210.         set %cxt_file ""                ; clear variables
  211.         set %cxt_line ""
  212.  
  213. !force  pipe-command %cxtn_cmd          ; perform database access, shell command
  214.         !if &seq $status FALSE
  215.           !return
  216.         !endif
  217.  
  218. !force  select-buffer command           ; get result buffer from pipe-command
  219.         !if &seq $status FALSE
  220.           !return
  221.         !endif
  222.  
  223. !force  beginning-of-file               ; go to file begin
  224.         !if &seq $status FALSE
  225.           !return
  226.         !endif
  227.  
  228.         set-mark                        ; extract target file name
  229.  
  230. !force  search-forward " "              ; search for first blank after file name
  231.         !if &seq $status FALSE
  232.           !return
  233.         !endif
  234.  
  235.         backward-character
  236.         copy-region
  237.         set %cxt_file $kill             ; store target file name
  238.         forward-character
  239.         set-mark                        ; extract target file line
  240.         end-of-line
  241.         copy-region
  242.         set %cxt_line $kill             ; store target file line
  243.  
  244. !force  delete-window                   ; delete command window
  245. !force  delete-buffer command           ; delete command buffer
  246. !force  next-buffer                     ; switch to next buffer just to hide command buf
  247.  
  248.         !if ¬ &exist %cxt_file       ; test if file exists
  249.           write-message &cat &cat "Target file ~"" %cxt_file "~" not found"
  250.           !return
  251.         !endif
  252.  
  253. !force  find-file %cxt_file             ; open target file
  254.  
  255.         !if &seq $status TRUE
  256. !force    goto-line %cxt_line           ; jump to target line
  257.  
  258.           !if &seq $status FALSE
  259.             clear-message-line
  260.             !return
  261.           !endif
  262.  
  263.           delete-other-windows          ; just for safety
  264.           redraw-display                ; center target line
  265.           clear-message-line
  266.         !endif
  267. !endm
  268.  
  269. ;*****************************************************************************
  270. ;* read search item from current buffer *
  271. ;*****************************************************************************
  272. store-procedure _extract_item
  273.         set %cxt_item ""                ; clear variable
  274.  
  275.         !if &seq &sindex %char_set &chr $curchar 0
  276.           !return                       ; not on a valid character
  277.         !endif
  278.  
  279. !force  end-of-word
  280.  
  281.         !while TRUE
  282. !force  previous-word
  283. !force  backward-character
  284.         !if &seq &sindex %char_set &chr $curchar 0
  285. !force    forward-character
  286.           !break
  287.         !endif
  288.         !endwhile
  289.  
  290.         set-mark                        ; mark first item character
  291.  
  292.         !while TRUE
  293. !force  end-of-word                     ; goto end of item
  294.         !if &seq &sindex %char_set &chr $curchar 0
  295.           !break
  296.         !endif
  297.         !endwhile
  298.  
  299.         copy-region
  300.         set %cxt_item $kill             ; store item name
  301. !endm
  302.  
  303. ;*****************************************************************************
  304. ;* read marked search item *
  305. ;*****************************************************************************
  306. store-procedure _extract_marked_item
  307.         set %cxt_item ""                                ; clear variable
  308. !force  copy-region
  309.         set %cxt_item $kill                             ; store item name
  310.  
  311.         !if ¬ &seq &len %cxt_item 0
  312.           set %cxt_item &cat &cat "~"" %cxt_item "~""   ; quote
  313.         !endif
  314. !endm
  315.  
  316. ;*****************************************************************************
  317. ;* bind macros to WINDOWS menu, only if MicroEMACS for WINDOWS is present *
  318. ;*****************************************************************************
  319. !if &seq $sres "MSWIN"          ; test, if this is running under MS Windows
  320.   ; insert separator
  321.   bind-to-menu  nop     ">&Miscellaneous>-@5"
  322.  
  323.   ; create a new underlying pop-up menu for the CFT macros
  324.   macro-to-menu cft     ">&Miscellaneous>C&FT macros@6>CFT &function search@0"
  325.   macro-to-menu cftmark "CFT function search &mark"
  326.   macro-to-menu cftfind "CFT function search &prompt"
  327.   macro-to-menu cftfile "CFT file&list"
  328.   macro-to-menu cftbase "CFT data&base name"
  329.   macro-to-menu cxtbase "CFT and CST database &name"
  330.  
  331.   ; create a new underlying pop-up menu for the CST macros
  332.   macro-to-menu cst     ">&Miscellaneous>C&ST macros@7>CST &data type search@0"
  333.   macro-to-menu cstmark "CST data type search &mark"
  334.   macro-to-menu cstfind "CST data type search &prompt"
  335.   macro-to-menu cstfile "CST file&list"
  336.   macro-to-menu cstbase "CST data&base name"
  337.   macro-to-menu cxtbase "CFT and CST database &name"
  338. !endif
  339.  
  340. ;*****************************************************************************
  341. ;**** write final message ****
  342. ;*****************************************************************************
  343. write-message "CXT macro package loaded"
  344.  
  345. ;**** THIS IS THE END THIS IS THE END THIS IS THE END THIS IS THE END ****
  346.  
  347.